# 统计图相关数据
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.decorators import api_view
from NetShop.models import Order

# 返回每个商品种类的总订单数
class StaticAnalysisOrder(APIView):
    def get(self,request):
        cat = Order.objects.filter(kind='猫').count()
        dog = Order.objects.filter(kind='狗').count()
        dog_eat = Order.objects.filter(kind='狗粮').count()
        cat_eat = Order.objects.filter(kind='猫粮').count()
        all = Order.objects.all().count()
        data = {
            'all':all,
            'cat':cat,
            'dog':dog,
            'dog_eat':dog_eat,
            'cat_eat':cat_eat
        }
        result = {
            'data': data,
            'code': 2000,
            'msg': '获取成功'
        }
        return Response(result)

@api_view(['GET'])
def StaticAnalysisUnDone(request):
    result = {
        'data': None,
        'code': 2000,
        'msg': '获取成功'
    }
    return Response(result)